﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using System.Windows.Media.Imaging;

namespace NUMIMAX
{
    public class Tools
    {
        /// <summary>
        /// Metoda generująca aktualną datę.
        /// </summary>
        /// <param name="type">Rodzaj separatora daty.</param>
        /// <returns>Zwracana jest aktualna data w postaci stringa.</returns>
        public static string GetTodayDate(Separator type)
        {
            string day, month, year, date, separator = null;

            switch (type)
            {
                case Separator.myslnik:
                    separator = "-";
                    break;
                case Separator.ukosnik:
                    separator = "/";
                    break;
                case Separator.kropka:
                    separator = ".";
                    break;
                case Separator.spacja:
                    separator = " ";
                    break;
                case Separator.brak:
                    separator = "";
                    break;
            }

            day = DateTime.Now.Day.ToString();
            month = DateTime.Now.Month.ToString();
            year = DateTime.Now.Year.ToString();

            if (day.Length == 1) day = "0" + day;
            if (month.Length == 1) month = "0" + month;
            if (year.Length == 1) year = "0" + year;

            return date = year + separator + month + separator + day;
        }

        /// <summary>
        /// Metoda konwertująca datę z formatu "DateTime" do stringa.
        /// </summary>
        /// <param name="date">Data.</param>
        /// <param name="type">Rodzaj separatora daty.</param>
        /// <returns>Data przekonwertowana do postaci stringa.</returns>
        public static string DateToString(DateTime date, Separator type)
        {
            string day, month, year, strDate, separator = null;

            switch (type)
            {
                case Separator.myslnik:
                    separator = "-";
                    break;
                case Separator.ukosnik:
                    separator = "/";
                    break;
                case Separator.kropka:
                    separator = ".";
                    break;
                case Separator.spacja:
                    separator = " ";
                    break;
                case Separator.brak:
                    separator = "";
                    break;
            }

            day = date.Day.ToString();
            month = date.Month.ToString();
            year = date.Year.ToString();

            if (day.Length == 1) day = "0" + day;
            if (month.Length == 1) month = "0" + month;
            if (year.Length == 1) year = "0" + year;

            return strDate = year + separator + month + separator + day;
        }

        public static string CutDate(string date)
        {
            return date.Substring(0, 4);
        }
    }

    public delegate void SetParameterValueDelegate(int index, int value);
    public delegate void AddItemDelegate(int index, int item, bool koniec);
    public delegate void AddItemCallbackFnDodajMonete(Coin _loadedCoins);

    public enum Separator : byte
    {
        myslnik,
        ukosnik,
        kropka,
        spacja,
        brak
    }
}
